#include <stdio.h>
#include <stdlib.h>

int main (int argc, char const* argv[])
{
    int k, m, i, a[500000];

    while (EOF != scanf("%d", &k)) {
        if (k == -1) break;

        a[0] = 0;
        for (m = 1; m <= k; m++) {
            a[m] = a[m-1] - m;
            if (a[m] < 0) {
                a[m] = a[m-1] + m;
            } else {
                for (i = 0; i < m - 1; i++) {
                    if (a[i] == a[m]) {
                        a[m] = a[m-1] + m;
                        break;
                    }
                }
            }
        }
        printf("%d\n", a[k]);
    }

    return 0;
}
